<?php
/**
 * Created by PhpStorm.
 * User: tri
 * Date: 8/10/2014
 * Time: 5:09 PM
 */

session_start();
error_reporting(1);
require_once('../../class_ajax_request/classAjax.php');
include_once('../../application/functions.php');
include_once('../../application/DataConfig.php');

if(isset($_POST)){
    $obj = new AjaxRequest();
    $idPost = $_POST['postId'];
    $page = $_POST['page'];
    $obj      = new AjaxRequest();
    //replay
    $getReply       = $obj->getReply( $idPost ,$page);
    $replyArr = '';

        $count = 1;
        for ( $u = 0; $u < count($getReply); ++$u ) {
            //<--- * User Verified * --->
            if( $getReply[$u]['type_account'] == 1 ) {
                $verified = ' <img class="verified_img" src="'.URL_BASE.'public/img/verified_min.png">';
            } else  {
                $verified = null;
            }
            //<--- * Delete Reply* --->
            if( $_SESSION['authenticated'] == $getReply[$u]['id'] ) {
                $removeReply = ' <i title="'.$_SESSION['LANG']['delete'].'" data="'.$getReply[$u]['idReply'].'" class="trash_ico_reply removeReply"></i>';
            } else {
                $removeReply = null;
            }
            $avatar = $getReply[$u]['avatar'];
            $avatar = _Function::checkExistsAvatar($avatar,'54-54');

            $replyArr .= "<span class='spanReply'>".$removeReply."<span class='paddingReply'>
			<a href='".URL_BASE.$getReply[$u]['username']."' class='openModal' data-id='".$getReply[$u]['id']."'>
				<img class='avatar_user' src='".$avatar."'>
			</a>
			 <span class='replyContainer'> <span class='timestamp timeAgo' data='".date('c', strtotime( $getReply[$u]['date'] ) )."'>
			 </span> <a href='".URL_BASE.$getReply[$u]['username']."' class='userR openModal' data-id='".$getReply[$u]['id']."'>".stripslashes( $getReply[$u]['name'] ).$verified."</a>
			 <strong class='usernameClass'>@".$getReply[$u]['username']."</strong> <p>"._Function::checkText( $getReply[$u]['reply'] )."</p>
			 </span></span> </span><!-- SPAN REPLY -->";
            $count++;
        }
   echo  $replyArr;
}
